home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / comm / term / term34Source.lha / ScreenPanel.c < prev    next >
C/C++ Source or Header  |  1993-07-16  |  35KB  |  1,215 lines

  1. /*
  2. **    ScreenPanel.c
  3. **
  4. **    Editing panel for screen configuration
  5. **
  6. **    Copyright © 1990-1993 by Olaf `Olsen' Barthel & MXM
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12. enum    {    GAD_MODES,GAD_MODE,GAD_NEWMODE,GAD_COLOUR,GAD_PALETTE,GAD_RED,GAD_GREEN,GAD_BLUE,GAD_STANDARD,
  13.         GAD_CURRENTFONT,GAD_NEWFONT,GAD_MAKEPUBLIC,GAD_SHANGHAI,GAD_BLINKING,GAD_FASTER_LAYOUT,
  14.         GAD_TITLEBAR,GAD_USE_WORKBENCH,GAD_PUBSCREEN_NAME,GAD_PICKSCREEN,GAD_STATUS_LINE,
  15.         GAD_TIMEDISPLAY,GAD_USE,GAD_CANCEL,GAD_DEFAULT };
  16.  
  17. struct ModeNode
  18. {
  19.     struct Node    VanillaNode;
  20.     ULONG        DisplayID;
  21. };
  22.  
  23. STATIC STRPTR        StatusType[4],
  24.             ColourType[5],
  25.             TimeType[4];
  26.  
  27. STATIC struct List    ModeList;
  28. STATIC BYTE        ModeLimited;
  29.  
  30.     /* ModeFilter(register __a1 ULONG ID):
  31.      *
  32.      *    Screen display mode filter, rejects all
  33.      *    modes unapproriate for screen display.
  34.      */
  35.  
  36. STATIC ULONG __saveds __asm
  37. ModeFilter(register __a1 ULONG ID)
  38. {
  39.     struct DimensionInfo DimensionInfo;
  40.  
  41.     if(GetDisplayInfoData(NULL,(APTR)&DimensionInfo,sizeof(struct DimensionInfo),DTAG_DIMS,ID))
  42.     {
  43.         if(DimensionInfo . TxtOScan . MaxX - DimensionInfo . TxtOScan . MinX + 1 >= 640)
  44.         {
  45.             if(ModeLimited)
  46.                 return((ULONG)ModeOkay(ID));
  47.             else
  48.                 return(TRUE);
  49.         }
  50.     }
  51.  
  52.     return(FALSE);
  53. }
  54.  
  55.     /* SelectDisplayMode(struct Window *Window,ULONG *Mode):
  56.      *
  57.      *    Select a screen display mode using asl.library.
  58.      */
  59.  
  60. STATIC BYTE __regargs
  61. SelectDisplayMode(struct Window *Window,ULONG *Mode)
  62. {
  63.     struct ScreenModeRequester    *Request;
  64.     struct Hook             FilterHook;
  65.     BYTE                 Result = FALSE;
  66.     LONG                 Left    = 0,
  67.                      Top    = 0,
  68.                      Width    = 0,
  69.                      Height    = 0;
  70.  
  71.     GetWindowInfo(WINDOW_SCREEN,&Left,&Top,&Width,&Height,Window -> Width / 2,Window -> Height / 2);
  72.  
  73.     FilterHook . h_Entry    = (LONG (*)())ModeFilter;
  74.     FilterHook . h_SubEntry    = NULL;
  75.     FilterHook . h_Data    = NULL;
  76.  
  77.     if(Request = (struct ScreenModeRequester *)AllocAslRequestTags(ASL_ScreenModeRequest,
  78.         ASLSM_Window,        Window,
  79.         ASLSM_InitialDisplayID,    *Mode,
  80.         ASLSM_FilterFunc,    &FilterHook,
  81.         ASLSM_PrivateIDCMP,    TRUE,
  82.         ASL_LeftEdge,        Left,
  83.         ASL_TopEdge,        Top,
  84.         ASL_Width,        Width,
  85.         ASL_Height,        Height,
  86.     TAG_DONE))
  87.     {
  88.         if(AslRequestTags(Request,TAG_DONE))
  89.         {
  90.             PutWindowInfo(WINDOW_SCREEN,Request -> sm_LeftEdge,Request -> sm_TopEdge,Request -> sm_Width,Request -> sm_Height);
  91.  
  92.             *Mode = Request -> sm_DisplayID;
  93.  
  94.             Result = TRUE;
  95.         }
  96.  
  97.         FreeAslRequest(Request);
  98.     }
  99.  
  100.     return(Result);
  101. }
  102.  
  103. STATIC struct Gadget *
  104. CreateAllGadgets(LONG *NumModes,struct Configuration *LocalConfig,struct Gadget **GadgetArray,struct Gadget **GadgetList,BYTE WrongMode,BYTE *Default)
  105. {
  106.     struct Gadget        *Gadget;
  107.     struct NewGadget     NewGadget;
  108.     UWORD             Counter = 0;
  109.     LONG             Mode;
  110.  
  111.     LocalizeString(StatusType,MSG_SCREENPANEL_STATUS_DISABLED_TXT,MSG_SCREENPANEL_STATUS_COMPACT_TXT);
  112.     LocalizeString(ColourType,MSG_SCREENPANEL_COLOUR_AMIGA_TXT,MSG_SCREENPANEL_COLOUR_MONO_TXT);
  113.     LocalizeString(TimeType,MSG_SCREENPANEL_TIME_ONLINETIME_TXT,MSG_SCREENPANEL_TIME_BOTH_TXT);
  114.  
  115.     SZ_SizeSetup(Window -> WScreen,&UserFont,TRUE);
  116.  
  117.     memset(&NewGadget,0,sizeof(struct NewGadget));
  118.  
  119.     if(Gadget = CreateContext(GadgetList))
  120.     {
  121.         NewList(&ModeList);
  122.  
  123.         if(LocalConfig -> ScreenConfig -> ColourMode == COLOUR_EIGHT || LocalConfig -> ScreenConfig -> ColourMode == COLOUR_SIXTEEN)
  124.             ModeLimited = TRUE;
  125.         else
  126.             ModeLimited = FALSE;
  127.  
  128.         SZ_ResetMaxWidth();
  129.  
  130.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_SELECT_NEW_DISPLAY_MODE_TXT),0,NULL);
  131.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_SCREENPANEL_USE_DEFAULT_TXT),0,NULL);
  132.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_SCREENPANEL_SELECT_NEW_FONT_TXT),0,NULL);
  133.         SZ_UpdateMaxWidth(CYCLE_KIND,NULL,0,ColourType);
  134.  
  135.         if(AslBase -> lib_Version < 38)
  136.         {
  137.             ULONG             SomeMode = INVALID_ID;
  138.             struct DisplayInfo     DisplayInfo;
  139.             LONG             Len,Max = 0;
  140.  
  141.             *NumModes = Mode = 0;
  142.  
  143.             while((SomeMode = NextDisplayInfo(SomeMode)) != INVALID_ID)
  144.             {
  145.                 if(ModeLimited)
  146.                 {
  147.                     if(!ModeOkay(SomeMode))
  148.                         continue;
  149.                 }
  150.  
  151.                 if(GetDisplayInfoData(NULL,(APTR)&DisplayInfo,sizeof(struct DisplayInfo),DTAG_DISP,SomeMode))
  152.                 {
  153.                     if(DisplayInfo . PropertyFlags & DIPF_IS_WB)
  154.                     {
  155.                         struct ModeNode    *Node;
  156.                         STRPTR         Name;
  157.  
  158.                         Name = GetModeName(SomeMode);
  159.  
  160.                         if((Len = strlen(Name)) > Max)
  161.                             Max = Len;
  162.  
  163.                         if(Node = (struct ModeNode *)AllocVec(sizeof(struct ModeNode) + Len + 1,MEMF_ANY | MEMF_CLEAR))
  164.                         {
  165.                             Node -> VanillaNode . ln_Name    = (char *)(Node + 1);
  166.                             Node -> DisplayID        = SomeMode;
  167.  
  168.                             strcpy(Node -> VanillaNode . ln_Name,Name);
  169.  
  170.                             AddTail(&ModeList,&Node -> VanillaNode);
  171.  
  172.                             if(LocalConfig -> ScreenConfig -> DisplayMode == SomeMode)
  173.                                 Mode = *NumModes;
  174.  
  175.                             *NumModes = *NumModes + 1;
  176.                         }
  177.                     }
  178.                 }
  179.             }
  180.  
  181.             SZ_UpdateMaxWidth(LISTVIEW_KIND,NULL,Max,NULL);
  182.             SZ_SetWidth(SZ_ResetMaxWidth());
  183.  
  184.             SZ_AddLeftOffset(SZ_LeftOffsetN(MSG_SCREENPANEL_AVAILABLE_DISPLAY_MODES_GAD,MSG_SCREENPANEL_COLOUR_GAD,MSG_SCREENPANEL_EDIT_SCREEN_PALETTE_GAD,MSG_SCREENPANEL_RED_GAD,MSG_SCREENPANEL_GREEN_GAD,MSG_SCREENPANEL_BLUE_GAD,MSG_SCREENPANEL_SCREEN_FONT_GAD,-1));
  185.  
  186.             NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_AVAILABLE_DISPLAY_MODES_GAD);
  187.             NewGadget . ng_GadgetID        = Counter;
  188.             NewGadget . ng_Flags        = PLACETEXT_LEFT;
  189.  
  190.             GadgetArray[Counter] = Gadget = CreateGadget(LISTVIEW_KIND,Gadget,&NewGadget,
  191.                 SZ_Adjust,        TRUE,
  192.                 SZ_AutoWidth,        TRUE,
  193.                 SZ_Lines,        4,
  194.  
  195.                 GTLV_Labels,        &ModeList,
  196.                 GTLV_ShowSelected,    NULL,
  197.                 GTLV_Selected,        Mode,
  198.                 GTLV_Top,        Mode,
  199.             TAG_DONE);
  200.         }
  201.         else
  202.         {
  203.             ULONG             SomeMode = INVALID_ID;
  204.             struct DisplayInfo     DisplayInfo;
  205.             LONG             Len,Max = 0;
  206.  
  207.             while((SomeMode = NextDisplayInfo(SomeMode)) != INVALID_ID)
  208.             {
  209.                 if(ModeLimited)
  210.                 {
  211.                     if(!ModeOkay(SomeMode))
  212.                         continue;
  213.                 }
  214.  
  215.                 if(GetDisplayInfoData(NULL,(APTR)&DisplayInfo,sizeof(struct DisplayInfo),DTAG_DISP,SomeMode))
  216.                 {
  217.                     if(DisplayInfo . PropertyFlags & DIPF_IS_WB)
  218.                     {
  219.                         if((Len = strlen(GetModeName(SomeMode))) > Max)
  220.                             Max = Len;
  221.                     }
  222.                 }
  223.             }
  224.  
  225.             SZ_UpdateMaxWidth(TEXT_KIND,NULL,Max,NULL);
  226.  
  227.             SZ_SetWidth(SZ_ResetMaxWidth());
  228.  
  229.             SZ_AddLeftOffset(SZ_LeftOffsetN(MSG_SCREENPANEL_CURRENT_DISPLAY_MODE_GAD,MSG_SCREENPANEL_COLOUR_GAD,MSG_SCREENPANEL_EDIT_SCREEN_PALETTE_GAD,MSG_SCREENPANEL_RED_GAD,MSG_SCREENPANEL_GREEN_GAD,MSG_SCREENPANEL_BLUE_GAD,MSG_SCREENPANEL_SCREEN_FONT_GAD,-1));
  230.  
  231.             Counter = GAD_MODE;
  232.  
  233.             NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_CURRENT_DISPLAY_MODE_GAD);
  234.             NewGadget . ng_GadgetID        = Counter;
  235.             NewGadget . ng_Flags        = PLACETEXT_LEFT;
  236.  
  237.             if(ModeNotAvailable(LocalConfig -> ScreenConfig -> DisplayMode))
  238.                 LocalConfig -> ScreenConfig -> DisplayMode = HIRES_KEY;
  239.  
  240.             GadgetArray[Counter++] = Gadget = CreateGadget(TEXT_KIND,Gadget,&NewGadget,
  241.                 SZ_Adjust,    TRUE,
  242.                 SZ_AutoWidth,    TRUE,
  243.  
  244.                 GTTX_Text,    GetModeName(LocalConfig -> ScreenConfig -> DisplayMode),
  245.                 GTTX_Border,    TRUE,
  246.             TAG_DONE);
  247.  
  248.             NewGadget . ng_GadgetText    = LocaleString(MSG_GLOBAL_SELECT_NEW_DISPLAY_MODE_TXT);
  249.             NewGadget . ng_GadgetID        = Counter;
  250.             NewGadget . ng_Flags        = 0;
  251.  
  252.             GadgetArray[Counter] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  253.                 SZ_Adjust,    TRUE,
  254.                 SZ_AutoWidth,    TRUE,
  255.             TAG_DONE);
  256.         }
  257.  
  258.         Counter = GAD_COLOUR;
  259.  
  260.         NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_COLOUR_GAD);
  261.         NewGadget . ng_GadgetID        = Counter;
  262.  
  263.         GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
  264.             SZ_Adjust,    TRUE,
  265.             SZ_AutoWidth,    TRUE,
  266.  
  267.             GTCY_Labels,    ColourType,
  268.             GTCY_Active,    LocalConfig -> ScreenConfig -> ColourMode,
  269.         TAG_DONE);
  270.  
  271.         NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_EDIT_SCREEN_PALETTE_GAD);
  272.         NewGadget . ng_GadgetID        = Counter;
  273.  
  274.         GadgetArray[Counter++] = Gadget = CreateGadget(PALETTE_KIND,Gadget,&NewGadget,
  275.             SZ_Adjust,        TRUE,
  276.             SZ_AutoWidth,        TRUE,
  277.             SZ_AlignExtra,        TRUE,
  278.  
  279.             GTPA_Depth,        Config -> ScreenConfig -> ColourMode == COLOUR_EIGHT ? 3 : MIN(Window -> WScreen -> RastPort . BitMap -> Depth,4),
  280.             GTPA_Color,        0,
  281.             GA_Disabled,        WrongMode,
  282.         TAG_DONE);
  283.  
  284.         NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_RED_GAD);
  285.         NewGadget . ng_GadgetID        = Counter;
  286.  
  287.         GadgetArray[Counter++] = Gadget = CreateGadget(SLIDER_KIND,Gadget,&NewGadget,
  288.             SZ_Adjust,        TRUE,
  289.             SZ_AutoWidth,        TRUE,
  290.  
  291.             GTSL_Min,        0,
  292.             GTSL_Max,        15,
  293.             GTSL_Level,        0,
  294.             GTSL_LevelFormat,    "%2ld",
  295.             GTSL_MaxLevelLen,    2,
  296.             GA_Disabled,        WrongMode,
  297.         TAG_DONE);
  298.  
  299.         NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_GREEN_GAD);
  300.         NewGadget . ng_GadgetID        = Counter;
  301.  
  302.         GadgetArray[Counter++] = Gadget = CreateGadget(SLIDER_KIND,Gadget,&NewGadget,
  303.             SZ_Adjust,        TRUE,
  304.             SZ_AutoWidth,        TRUE,
  305.  
  306.             GTSL_Min,        0,
  307.             GTSL_Max,        15,
  308.             GTSL_Level,        0,
  309.             GTSL_LevelFormat,    "%2ld",
  310.             GTSL_MaxLevelLen,    2,
  311.             GA_Disabled,        WrongMode,
  312.         TAG_DONE);
  313.  
  314.         NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_BLUE_GAD);
  315.         NewGadget . ng_GadgetID        = Counter;
  316.  
  317.         GadgetArray[Counter++] = Gadget = CreateGadget(SLIDER_KIND,Gadget,&NewGadget,
  318.             SZ_Adjust,        TRUE,
  319.             SZ_AutoWidth,        TRUE,
  320.  
  321.             GTSL_Min,        0,
  322.             GTSL_Max,        15,
  323.             GTSL_Level,        0,
  324.             GTSL_LevelFormat,    "%2ld",
  325.             GTSL_MaxLevelLen,    2,
  326.             GA_Disabled,        WrongMode,
  327.         TAG_DONE);
  328.  
  329.         NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_USE_DEFAULT_TXT);
  330.         NewGadget . ng_GadgetID        = Counter;
  331.         NewGadget . ng_Flags        = 0;
  332.  
  333.         GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  334.             SZ_Adjust,    TRUE,
  335.             SZ_AutoWidth,    TRUE,
  336.  
  337.             GA_Disabled,    WrongMode,
  338.         TAG_DONE);
  339.  
  340.         NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_SCREEN_FONT_GAD);
  341.         NewGadget . ng_GadgetID        = Counter;
  342.  
  343.         GadgetArray[Counter++] = Gadget = CreateGadget(TEXT_KIND,Gadget,&NewGadget,
  344.             SZ_Adjust,    TRUE,
  345.             SZ_AutoWidth,    TRUE,
  346.             SZ_AlignExtra,    TRUE,
  347.  
  348.             GTTX_Border,    TRUE,
  349.         TAG_DONE);
  350.  
  351.         NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_SELECT_NEW_FONT_TXT);
  352.         NewGadget . ng_GadgetID        = Counter;
  353.         NewGadget . ng_Flags        = 0;
  354.  
  355.         GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  356.             SZ_Adjust,    TRUE,
  357.             SZ_AutoWidth,    TRUE,
  358.             GA_Disabled,    LocalConfig -> ScreenConfig -> UseWorkbench,
  359.         TAG_DONE);
  360.  
  361.         SZ_AddLeftOffset(SZ_LeftOffsetDelta(MSG_SCREENPANEL_MAKE_SCREEN_PUBLIC_GAD,MSG_SCREENPANEL_STATUS_LINE_GAD));
  362.  
  363.         SZ_ResetMaxWidth();
  364.  
  365.         SZ_UpdateMaxWidth(CYCLE_KIND,NULL,0,StatusType);
  366.         SZ_UpdateMaxWidth(CYCLE_KIND,NULL,0,TimeType);
  367.  
  368.         SZ_SetWidth(SZ_ResetMaxWidth());
  369.  
  370.         NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_MAKE_SCREEN_PUBLIC_GAD);
  371.         NewGadget . ng_GadgetID        = Counter;
  372.  
  373.         GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
  374.             SZ_Adjust,    TRUE,
  375.             SZ_AutoWidth,    TRUE,
  376.             SZ_NewColumn,    TRUE,
  377.  
  378.             GTCB_Checked,    LocalConfig -> ScreenConfig -> MakeScreenPublic,
  379.             GA_Disabled,    LocalConfig -> ScreenConfig -> UseWorkbench,
  380.         TAG_DONE);
  381.  
  382.         NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_SHANGHAI_WINDOWS_GAD);
  383.         NewGadget . ng_GadgetID        = Counter;
  384.  
  385.         GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
  386.             SZ_Adjust,    TRUE,
  387.             SZ_AutoWidth,    TRUE,
  388.  
  389.             GTCB_Checked,    LocalConfig -> ScreenConfig -> ShanghaiWindows,
  390.             GA_Disabled,    !LocalConfig -> ScreenConfig -> MakeScreenPublic || LocalConfig -> ScreenConfig -> UseWorkbench,
  391.         TAG_DONE);
  392.  
  393.         NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_BLINKING_GAD);
  394.         NewGadget . ng_GadgetID        = Counter;
  395.  
  396.         GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
  397.             SZ_Adjust,    TRUE,
  398.             SZ_AutoWidth,    TRUE,
  399.             SZ_AlignExtra,    TRUE,
  400.  
  401.             GTCB_Checked,    LocalConfig -> ScreenConfig -> Blinking,
  402.             GA_Disabled,    LocalConfig -> ScreenConfig -> UseWorkbench,
  403.         TAG_DONE);
  404.  
  405.         NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_FASTER_LAYOUT_GAD);
  406.         NewGadget . ng_GadgetID        = Counter;
  407.  
  408.         GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
  409.             SZ_Adjust,    TRUE,
  410.             SZ_AutoWidth,    TRUE,
  411.  
  412.             GTCB_Checked,    LocalConfig -> ScreenConfig -> FasterLayout,
  413.             GA_Disabled,    LocalConfig -> ScreenConfig -> UseWorkbench,
  414.         TAG_DONE);
  415.  
  416.         NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_SCREEN_TITLE_GAD);
  417.         NewGadget . ng_GadgetID        = Counter;
  418.  
  419.         GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
  420.             SZ_Adjust,    TRUE,
  421.             SZ_AutoWidth,    TRUE,
  422.  
  423.             GTCB_Checked,    LocalConfig -> ScreenConfig -> TitleBar,
  424.             GA_Disabled,    LocalConfig -> ScreenConfig -> UseWorkbench,
  425.         TAG_DONE);
  426.  
  427.         NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_USE_WORKBENCH_GAD);
  428.         NewGadget . ng_GadgetID        = Counter;
  429.  
  430.         GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
  431.             SZ_Adjust,    TRUE,
  432.             SZ_AutoWidth,    TRUE,
  433.  
  434.             GTCB_Checked,    LocalConfig -> ScreenConfig -> UseWorkbench,
  435.         TAG_DONE);
  436.  
  437.         NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_PUBSCREEN_NAME_GAD);
  438.         NewGadget . ng_GadgetID        = Counter;
  439.  
  440.         GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
  441.             SZ_Adjust,    TRUE,
  442.             SZ_AutoWidth,    TRUE,
  443.             SZ_LeaveFolder,    TRUE,
  444.  
  445.             GTST_MaxChars,    MAXPUBSCREENNAME,
  446.             GTST_String,    LocalConfig -> ScreenConfig -> PubScreenName,
  447.             GA_Disabled,    !LocalConfig -> ScreenConfig -> UseWorkbench,
  448.         TAG_DONE);
  449.  
  450.         NewGadget . ng_GadgetID = Counter;
  451.  
  452.         GadgetArray[Counter++] = Gadget = CreateGadget(SCREEN_KIND,Gadget,&NewGadget,
  453.             SZ_Adjust,    TRUE,
  454.             SZ_AutoWidth,    TRUE,
  455.             SZ_PlaceLeft,    TRUE,
  456.         TAG_DONE);
  457.  
  458.         NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_STATUS_LINE_GAD);
  459.         NewGadget . ng_GadgetID        = Counter;
  460.  
  461.         GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
  462.             SZ_Adjust,    TRUE,
  463.             SZ_AutoWidth,    TRUE,
  464.  
  465.             GTCY_Labels,    StatusType,
  466.             GTCY_Active,    LocalConfig -> ScreenConfig -> StatusLine,
  467.         TAG_DONE);
  468.  
  469.         NewGadget . ng_GadgetText    = LocaleString(MSG_SCREENPANEL_ONLINE_TIME_GAD);
  470.         NewGadget . ng_GadgetID        = Counter;
  471.  
  472.         GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
  473.             SZ_Adjust,    TRUE,
  474.             SZ_AutoWidth,    TRUE,
  475.             SZ_AlignExtra,    TRUE,
  476.  
  477.             GTCY_Labels,    TimeType,
  478.             GTCY_Active,    LocalConfig -> ScreenConfig -> TimeMode,
  479.         TAG_DONE);
  480.  
  481.         NewGadget . ng_GadgetText    = LocaleString(MSG_GLOBAL_USE_GAD);
  482.         NewGadget . ng_GadgetID        = Counter;
  483.         NewGadget . ng_Flags        = 0;
  484.  
  485.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_USE_GAD),0,NULL);
  486.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_CANCEL_GAD),0,NULL);
  487.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_DEFAULT_GAD),0,NULL);
  488.  
  489.         SZ_SetWidth(SZ_ResetMaxWidth());
  490.  
  491.         GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  492.             SZ_Adjust,    TRUE,
  493.             SZ_AutoWidth,    TRUE,
  494.             SZ_AlignExtra,    TRUE,
  495.             SZ_AlignLeft,    TRUE,
  496.             SZ_AlignBottom,    TRUE,
  497.         TAG_DONE);
  498.  
  499.         NewGadget . ng_GadgetText    = LocaleString(MSG_GLOBAL_CANCEL_GAD);
  500.         NewGadget . ng_GadgetID        = Counter;
  501.  
  502.         GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  503.             SZ_Adjust,    TRUE,
  504.             SZ_AutoWidth,    TRUE,
  505.             SZ_AlignRight,    TRUE,
  506.         TAG_DONE);
  507.  
  508.         if(Default)
  509.         {
  510.             NewGadget . ng_GadgetText    = LocaleString(MSG_GLOBAL_DEFAULT_GAD);
  511.             NewGadget . ng_GadgetID        = Counter;
  512.  
  513.             GadgetArray[Counter] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  514.                 SZ_Adjust,    TRUE,
  515.                 SZ_AutoWidth,    TRUE,
  516.                 SZ_AlignCentre,    TRUE,
  517.             TAG_DONE);
  518.         }
  519.     }
  520.  
  521.     return(Gadget);
  522. }
  523.  
  524. STATIC BYTE
  525. IsWrongMode(struct Configuration *MyConfig,WORD OriginalMode)
  526. {
  527.     if(Config -> ScreenConfig -> ColourMode != OriginalMode || MyConfig -> ScreenConfig -> UseWorkbench || Config -> ScreenConfig -> UseWorkbench || !Screen)
  528.         return(TRUE);
  529.     else
  530.     {
  531.         switch(MyConfig -> ScreenConfig -> ColourMode)
  532.         {
  533.             case COLOUR_AMIGA:
  534.  
  535.                 if(Window -> WScreen -> RastPort . BitMap -> Depth < 2)
  536.                     return(TRUE);
  537.  
  538.                 break;
  539.  
  540.             case COLOUR_EIGHT:
  541.  
  542.                 if(Window -> WScreen -> RastPort . BitMap -> Depth < 3)
  543.                     return(TRUE);
  544.  
  545.                 break;
  546.  
  547.             case COLOUR_SIXTEEN:
  548.  
  549.                 if(Window -> WScreen -> RastPort . BitMap -> Depth < 4)
  550.                     return(TRUE);
  551.  
  552.                 break;
  553.  
  554.             case COLOUR_MONO:
  555.  
  556.                 if(Window -> WScreen -> RastPort . BitMap -> Depth > 1)
  557.                     return(TRUE);
  558.  
  559.                 break;
  560.         }
  561.  
  562.         return(FALSE);
  563.     }
  564. }
  565.  
  566. BYTE
  567. ScreenPanel(struct Configuration *MyConfig,BYTE *Default)
  568. {
  569.     struct Window    *PanelWindow;
  570.     struct Gadget    *GadgetList = NULL;
  571.     struct Gadget    *GadgetArray[GAD_DEFAULT + 1];
  572.     LONG         NumModes;
  573.  
  574.     BYTE         WrongMode;
  575.     struct ModeNode    *Node,*Next;
  576.  
  577.     SaveConfig(MyConfig,PrivateConfig);
  578.  
  579.     WrongMode = IsWrongMode(MyConfig,PrivateConfig -> ScreenConfig -> ColourMode);
  580.  
  581.     if(CreateAllGadgets(&NumModes,MyConfig,GadgetArray,&GadgetList,WrongMode,Default))
  582.     {
  583.         if(PanelWindow = OpenWindowTags(NULL,
  584.             WA_Left,    GetScreenLeft(Window) + (GetScreenWidth(Window) - SZ_GetWindowWidth()) / 2,
  585.             WA_Top,        GetScreenTop(Window) + (GetScreenHeight(Window) - SZ_GetWindowHeight())    / 2,
  586.             WA_Width,    SZ_GetWindowWidth(),
  587.             WA_Height,    SZ_GetWindowHeight(),
  588.  
  589.             WA_Activate,    TRUE,
  590.             WA_DragBar,    TRUE,
  591.             WA_DepthGadget,    TRUE,
  592.             WA_RMBTrap,    TRUE,
  593.             WA_DepthGadget,    TRUE,
  594.             WA_CloseGadget,    TRUE,
  595.             WA_CustomScreen,Window -> WScreen,
  596.  
  597.             WA_IDCMP,    IDCMP_GADGETDOWN | IDCMP_ACTIVEWINDOW | IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY | IDCMP_RAWKEY | STRINGIDCMP | SLIDERIDCMP | CHECKBOXIDCMP | LISTVIEWIDCMP | PALETTEIDCMP | BUTTONIDCMP | CYCLEIDCMP,
  598.  
  599.             WA_Title,    LocaleString(MSG_SCREENPANEL_SCREEN_PREFERENCES_TXT),
  600.         TAG_DONE))
  601.         {
  602.             struct IntuiMessage    *Massage;
  603.             ULONG             IClass,Code;
  604.             struct Gadget        *Gadget;
  605.             BYTE             Terminated = FALSE;
  606.  
  607.             LONG             ColourNumber = 0;
  608.             BYTE             Red,Green,Blue;
  609.  
  610.             GuideContext(CONTEXT_SCREEN);
  611.  
  612.             PushWindow(PanelWindow);
  613.  
  614.             AddGList(PanelWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
  615.             RefreshGList(GadgetList,PanelWindow,NULL,(UWORD)-1);
  616.             GT_RefreshWindow(PanelWindow,NULL);
  617.  
  618.             if(!WrongMode)
  619.             {
  620.                 Red    = (MyConfig -> ScreenConfig -> Colours[ColourNumber] >> 8) & 0xF;
  621.                 Green    = (MyConfig -> ScreenConfig -> Colours[ColourNumber] >> 4) & 0xF;
  622.                 Blue    = (MyConfig -> ScreenConfig -> Colours[ColourNumber]     ) & 0xF;
  623.  
  624.                 GT_SetGadgetAttrs(GadgetArray[GAD_RED],PanelWindow,NULL,
  625.                     GTSL_Level,Red,
  626.                 TAG_DONE);
  627.  
  628.                 GT_SetGadgetAttrs(GadgetArray[GAD_GREEN],PanelWindow,NULL,
  629.                     GTSL_Level,Green,
  630.                 TAG_DONE);
  631.  
  632.                 GT_SetGadgetAttrs(GadgetArray[GAD_BLUE],PanelWindow,NULL,
  633.                     GTSL_Level,Blue,
  634.                 TAG_DONE);
  635.             }
  636.  
  637.             SPrintf(SharedBuffer,"%s %ld",MyConfig -> ScreenConfig -> FontName,MyConfig -> ScreenConfig -> FontHeight);
  638.  
  639.             GT_SetGadgetAttrs(GadgetArray[GAD_CURRENTFONT],PanelWindow,NULL,
  640.                 GTTX_Text,    SharedBuffer,
  641.             TAG_DONE);
  642.  
  643.             if(!WrongMode && Screen)
  644.                 LoadRGB4(VPort,NormalColours,PaletteSize);
  645.  
  646.             ActiveGadget = NULL;
  647.  
  648.             ClrSignal(SIG_BREAK);
  649.  
  650.             while(!Terminated)
  651.             {
  652.                 if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
  653.                 {
  654.                     SaveConfig(PrivateConfig,MyConfig);
  655.  
  656.                     if(!Config -> ScreenConfig -> UseWorkbench && Screen)
  657.                     {
  658.                         if(!memcmp(Config -> ScreenConfig -> Colours,MyConfig -> ScreenConfig -> Colours,sizeof(UWORD) * 16))
  659.                             PaletteSetup(MyConfig);
  660.                         else
  661.                             PaletteSetup(Config);
  662.  
  663.                         LoadRGB4(VPort,NormalColours,PaletteSize);
  664.                     }
  665.  
  666.                     break;
  667.                 }
  668.  
  669.                 while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
  670.                 {
  671.                     IClass    = Massage -> Class;
  672.                     Code    = Massage -> Code;
  673.                     Gadget    = (struct Gadget *)Massage -> IAddress;
  674.  
  675.                     GT_ReplyIMsg(Massage);
  676.  
  677.                     KeySelect(GadgetArray,GAD_CANCEL,Code,PanelWindow,&Gadget,&IClass,&Code);
  678.  
  679.                     if(IClass == IDCMP_ACTIVEWINDOW && ActiveGadget)
  680.                         ActivateGadget(ActiveGadget,PanelWindow,NULL);
  681.  
  682.                     if(IClass == IDCMP_GADGETDOWN)
  683.                     {
  684.                         if((Gadget -> GadgetType & GTYP_GTYPEMASK) == GTYP_STRGADGET)
  685.                             ActiveGadget = Gadget;
  686.                     }
  687.  
  688.                     if(IClass == IDCMP_CLOSEWINDOW)
  689.                     {
  690.                         SaveConfig(PrivateConfig,MyConfig);
  691.  
  692.                         if(!MyConfig -> ScreenConfig -> UseWorkbench && Screen)
  693.                         {
  694.                             if(!memcmp(Config -> ScreenConfig -> Colours,MyConfig -> ScreenConfig -> Colours,sizeof(UWORD) * 16))
  695.                                 PaletteSetup(MyConfig);
  696.                             else
  697.                                 PaletteSetup(Config);
  698.  
  699.                             LoadRGB4(VPort,NormalColours,PaletteSize);
  700.                         }
  701.  
  702.                         Terminated = TRUE;
  703.                     }
  704.  
  705.                     if(IClass == IDCMP_MOUSEMOVE)
  706.                     {
  707.                         switch(Gadget -> GadgetID)
  708.                         {
  709.                             case GAD_RED:
  710.  
  711.                                 Red = Code;
  712.  
  713.                                 MyConfig -> ScreenConfig -> Colours[ColourNumber] = (Red << 8) | (Green << 4) | (Blue);
  714.  
  715.                                 PaletteSetup(MyConfig);
  716.                                 LoadRGB4(VPort,NormalColours,PaletteSize);
  717.  
  718.                                 break;
  719.  
  720.                             case GAD_GREEN:
  721.  
  722.                                 Green = Code;
  723.  
  724.                                 MyConfig -> ScreenConfig -> Colours[ColourNumber] = (Red << 8) | (Green << 4) | (Blue);
  725.  
  726.                                 PaletteSetup(MyConfig);
  727.                                 LoadRGB4(VPort,NormalColours,PaletteSize);
  728.  
  729.                                 break;
  730.  
  731.                             case GAD_BLUE:
  732.  
  733.                                 Blue = Code;
  734.  
  735.                                 MyConfig -> ScreenConfig -> Colours[ColourNumber] = (Red << 8) | (Green << 4) | (Blue);
  736.  
  737.                                 PaletteSetup(MyConfig);
  738.                                 LoadRGB4(VPort,NormalColours,PaletteSize);
  739.  
  740.                                 break;
  741.                         }
  742.                     }
  743.  
  744.                     if(IClass == IDCMP_GADGETUP)
  745.                     {
  746.                         switch(Gadget -> GadgetID)
  747.                         {
  748.                             case GAD_USE_WORKBENCH:
  749.  
  750.                                 if(SZ_GetChecked(Gadget))
  751.                                 {
  752.                                     MyConfig -> ScreenConfig -> UseWorkbench = TRUE;
  753.  
  754.                                     GT_SetGadgetAttrs(GadgetArray[GAD_NEWFONT],PanelWindow,NULL,
  755.                                         GA_Disabled,TRUE,
  756.                                     TAG_DONE);
  757.  
  758.                                     GT_SetGadgetAttrs(GadgetArray[GAD_BLINKING],PanelWindow,NULL,
  759.                                         GA_Disabled,    TRUE,
  760.                                         GTCB_Checked,    FALSE,
  761.                                     TAG_DONE);
  762.  
  763.                                     GT_SetGadgetAttrs(GadgetArray[GAD_FASTER_LAYOUT],PanelWindow,NULL,
  764.                                         GA_Disabled,    TRUE,
  765.                                         GTCB_Checked,    FALSE,
  766.                                     TAG_DONE);
  767.  
  768.                                     GT_SetGadgetAttrs(GadgetArray[GAD_TITLEBAR],PanelWindow,NULL,
  769.                                         GA_Disabled,TRUE,
  770.                                     TAG_DONE);
  771.  
  772.                                     GT_SetGadgetAttrs(GadgetArray[GAD_MAKEPUBLIC],PanelWindow,NULL,
  773.                                         GA_Disabled,TRUE,
  774.                                     TAG_DONE);
  775.  
  776.                                     GT_SetGadgetAttrs(GadgetArray[GAD_SHANGHAI],PanelWindow,NULL,
  777.                                         GA_Disabled,TRUE,
  778.                                     TAG_DONE);
  779.  
  780.                                     GT_SetGadgetAttrs(GadgetArray[GAD_PUBSCREEN_NAME],PanelWindow,NULL,
  781.                                         GA_Disabled,FALSE,
  782.                                     TAG_DONE);
  783.                                 }
  784.                                 else
  785.                                 {
  786.                                     MyConfig -> ScreenConfig -> UseWorkbench = FALSE;
  787.  
  788.                                     GT_SetGadgetAttrs(GadgetArray[GAD_NEWFONT],PanelWindow,NULL,
  789.                                         GA_Disabled,FALSE,
  790.                                     TAG_DONE);
  791.  
  792.                                     GT_SetGadgetAttrs(GadgetArray[GAD_BLINKING],PanelWindow,NULL,
  793.                                         GA_Disabled,FALSE,
  794.                                     TAG_DONE);
  795.  
  796.                                     GT_SetGadgetAttrs(GadgetArray[GAD_FASTER_LAYOUT],PanelWindow,NULL,
  797.                                         GA_Disabled,FALSE,
  798.                                     TAG_DONE);
  799.  
  800.                                     GT_SetGadgetAttrs(GadgetArray[GAD_TITLEBAR],PanelWindow,NULL,
  801.                                         GA_Disabled,FALSE,
  802.                                     TAG_DONE);
  803.  
  804.                                     GT_SetGadgetAttrs(GadgetArray[GAD_MAKEPUBLIC],PanelWindow,NULL,
  805.                                         GA_Disabled,FALSE,
  806.                                     TAG_DONE);
  807.  
  808.                                     GT_SetGadgetAttrs(GadgetArray[GAD_SHANGHAI],PanelWindow,NULL,
  809.                                         GA_Disabled,!MyConfig -> ScreenConfig -> MakeScreenPublic,
  810.                                     TAG_DONE);
  811.  
  812.                                     GT_SetGadgetAttrs(GadgetArray[GAD_PUBSCREEN_NAME],PanelWindow,NULL,
  813.                                         GA_Disabled,TRUE,
  814.                                     TAG_DONE);
  815.                                 }
  816.  
  817.                                 break;
  818.  
  819.                             case GAD_STATUS_LINE:
  820.  
  821.                                 MyConfig -> ScreenConfig -> StatusLine = Code;
  822.                                 break;
  823.  
  824.                             case GAD_TIMEDISPLAY:
  825.  
  826.                                 MyConfig -> ScreenConfig -> TimeMode = Code;
  827.                                 break;
  828.  
  829.                             case GAD_COLOUR:
  830.  
  831.                                 MyConfig -> ScreenConfig -> ColourMode = Code;
  832.  
  833.                                 if(!ModeOkay(MyConfig -> ScreenConfig -> DisplayMode) && MyConfig -> ScreenConfig -> ColourMode > COLOUR_AMIGA)
  834.                                 {
  835.                                     MyConfig -> ScreenConfig -> ColourMode = COLOUR_MONO;
  836.  
  837.                                     GT_SetGadgetAttrs(GadgetArray[GAD_COLOUR],PanelWindow,NULL,
  838.                                         GTCY_Active,COLOUR_MONO,
  839.                                     TAG_DONE);
  840.                                 }
  841.  
  842.                                 WrongMode = IsWrongMode(MyConfig,PrivateConfig -> ScreenConfig -> ColourMode);
  843.  
  844.                                 GT_SetGadgetAttrs(GadgetArray[GAD_PALETTE],PanelWindow,NULL,
  845.                                     GA_Disabled,WrongMode,
  846.                                 TAG_DONE);
  847.  
  848.                                 GT_SetGadgetAttrs(GadgetArray[GAD_RED],PanelWindow,NULL,
  849.                                     GA_Disabled,WrongMode,
  850.                                 TAG_DONE);
  851.  
  852.                                 GT_SetGadgetAttrs(GadgetArray[GAD_GREEN],PanelWindow,NULL,
  853.                                     GA_Disabled,WrongMode,
  854.                                 TAG_DONE);
  855.  
  856.                                 GT_SetGadgetAttrs(GadgetArray[GAD_BLUE],PanelWindow,NULL,
  857.                                     GA_Disabled,WrongMode,
  858.                                 TAG_DONE);
  859.  
  860.                                 GT_SetGadgetAttrs(GadgetArray[GAD_STANDARD],PanelWindow,NULL,
  861.                                     GA_Disabled,WrongMode,
  862.                                 TAG_DONE);
  863.  
  864.                                 if(MyConfig -> ScreenConfig -> UseWorkbench)
  865.                                 {
  866.                                     GT_SetGadgetAttrs(GadgetArray[GAD_BLINKING],PanelWindow,NULL,
  867.                                         GA_Disabled,    TRUE,
  868.                                         GTCB_Checked,    FALSE,
  869.                                     TAG_DONE);
  870.                                 }
  871.                                 else
  872.                                 {
  873.                                     if(MyConfig -> ScreenConfig -> ColourMode == COLOUR_MONO)
  874.                                     {
  875.                                         GT_SetGadgetAttrs(GadgetArray[GAD_BLINKING],PanelWindow,NULL,
  876.                                             GA_Disabled,    TRUE,
  877.                                             GTCB_Checked,    FALSE,
  878.                                         TAG_DONE);
  879.                                     }
  880.                                 }
  881.  
  882.                                 break;
  883.  
  884.                             case GAD_RED:
  885.  
  886.                                 Red = Code;
  887.  
  888.                                 MyConfig -> ScreenConfig -> Colours[ColourNumber] = (Red << 8) | (Green << 4) | (Blue);
  889.  
  890.                                 PaletteSetup(MyConfig);
  891.                                 LoadRGB4(VPort,NormalColours,PaletteSize);
  892.  
  893.                                 break;
  894.  
  895.                             case GAD_GREEN:
  896.  
  897.                                 Green = Code;
  898.  
  899.                                 MyConfig -> ScreenConfig -> Colours[ColourNumber] = (Red << 8) | (Green << 4) | (Blue);
  900.  
  901.                                 PaletteSetup(MyConfig);
  902.                                 LoadRGB4(VPort,NormalColours,PaletteSize);
  903.  
  904.                                 break;
  905.  
  906.                             case GAD_BLUE:
  907.  
  908.                                 Blue = Code;
  909.  
  910.                                 MyConfig -> ScreenConfig -> Colours[ColourNumber] = (Red << 8) | (Green << 4) | (Blue);
  911.  
  912.                                 PaletteSetup(MyConfig);
  913.                                 LoadRGB4(VPort,NormalColours,PaletteSize);
  914.  
  915.                                 break;
  916.  
  917.                             case GAD_STANDARD:
  918.  
  919.                                 switch(MyConfig -> ScreenConfig -> ColourMode)
  920.                                 {
  921.                                     case COLOUR_AMIGA:
  922.  
  923.                                         CopyMem(DefaultColours,MyConfig -> ScreenConfig -> Colours,16 * sizeof(UWORD));
  924.                                         break;
  925.  
  926.                                     case COLOUR_EIGHT:
  927.  
  928.                                         CopyMem(ANSIColours,MyConfig -> ScreenConfig -> Colours,16 * sizeof(UWORD));
  929.                                         break;
  930.  
  931.                                     case COLOUR_SIXTEEN:
  932.  
  933.                                         CopyMem(EGAColours,MyConfig -> ScreenConfig -> Colours,16 * sizeof(UWORD));
  934.                                         break;
  935.  
  936.                                     case COLOUR_MONO:
  937.  
  938.                                         CopyMem(AtomicColours,MyConfig -> ScreenConfig -> Colours,16 * sizeof(UWORD));
  939.                                         break;
  940.                                 }
  941.  
  942.                                 Red    = (MyConfig -> ScreenConfig -> Colours[ColourNumber] >> 8) & 0xF;
  943.                                 Green    = (MyConfig -> ScreenConfig -> Colours[ColourNumber] >> 4) & 0xF;
  944.                                 Blue    = (MyConfig -> ScreenConfig -> Colours[ColourNumber]     ) & 0xF;
  945.  
  946.                                 GT_SetGadgetAttrs(GadgetArray[GAD_RED],PanelWindow,NULL,
  947.                                     GTSL_Level,Red,
  948.                                 TAG_DONE);
  949.  
  950.                                 GT_SetGadgetAttrs(GadgetArray[GAD_GREEN],PanelWindow,NULL,
  951.                                     GTSL_Level,Green,
  952.                                 TAG_DONE);
  953.  
  954.                                 GT_SetGadgetAttrs(GadgetArray[GAD_BLUE],PanelWindow,NULL,
  955.                                     GTSL_Level,Blue,
  956.                                 TAG_DONE);
  957.  
  958.                                 PaletteSetup(MyConfig);
  959.                                 LoadRGB4(VPort,NormalColours,PaletteSize);
  960.  
  961.                                 break;
  962.  
  963.                             case GAD_MAKEPUBLIC:
  964.  
  965.                                 if(!SZ_GetChecked(Gadget))
  966.                                 {
  967.                                     GT_SetGadgetAttrs(GadgetArray[GAD_SHANGHAI],PanelWindow,NULL,
  968.                                         GTCB_Checked,    FALSE,
  969.                                         GA_Disabled,    TRUE,
  970.                                     TAG_DONE);
  971.                                 }
  972.                                 else
  973.                                 {
  974.                                     GT_SetGadgetAttrs(GadgetArray[GAD_SHANGHAI],PanelWindow,NULL,
  975.                                         GA_Disabled,    FALSE,
  976.                                     TAG_DONE);
  977.                                 }
  978.  
  979.                                 break;
  980.  
  981.                             case GAD_MODES:    
  982.  
  983.                                 if(Node = (struct ModeNode *)GetListNode(Code,&ModeList))
  984.                                 {
  985.                                     MyConfig -> ScreenConfig -> DisplayMode = Node -> DisplayID;
  986.  
  987.                                     if(!ModeOkay(MyConfig -> ScreenConfig -> DisplayMode) && MyConfig -> ScreenConfig -> ColourMode > COLOUR_AMIGA)
  988.                                     {
  989.                                         MyConfig -> ScreenConfig -> ColourMode = COLOUR_AMIGA;
  990.  
  991.                                         GT_SetGadgetAttrs(GadgetArray[GAD_COLOUR],PanelWindow,NULL,
  992.                                             GTCY_Active,COLOUR_AMIGA,
  993.                                         TAG_DONE);
  994.                                     }
  995.                                 }
  996.  
  997.                                 break;
  998.  
  999.                             case GAD_NEWMODE:
  1000.  
  1001.                                 BlockWindow(PanelWindow);
  1002.  
  1003.                                 if(SelectDisplayMode(PanelWindow,&MyConfig -> ScreenConfig -> DisplayMode))
  1004.                                 {
  1005.                                     GT_SetGadgetAttrs(GadgetArray[GAD_MODE],PanelWindow,NULL,
  1006.                                         GTTX_Text,    GetModeName(MyConfig -> ScreenConfig -> DisplayMode),
  1007.                                     TAG_DONE);
  1008.  
  1009.                                     if(!ModeOkay(MyConfig -> ScreenConfig -> DisplayMode) && MyConfig -> ScreenConfig -> ColourMode > COLOUR_AMIGA)
  1010.                                     {
  1011.                                         MyConfig -> ScreenConfig -> ColourMode = COLOUR_AMIGA;
  1012.  
  1013.                                         GT_SetGadgetAttrs(GadgetArray[GAD_COLOUR],PanelWindow,NULL,
  1014.                                             GTCY_Active,COLOUR_AMIGA,
  1015.                                         TAG_DONE);
  1016.                                     }
  1017.                                 }
  1018.  
  1019.                                 ReleaseWindow(PanelWindow);
  1020.  
  1021.                                 break;
  1022.  
  1023.                             case GAD_PALETTE:
  1024.  
  1025.                                 ColourNumber = Code;
  1026.  
  1027. SetPalette:                            Red    = (MyConfig -> ScreenConfig -> Colours[ColourNumber] >> 8) & 0xF;
  1028.                                 Green    = (MyConfig -> ScreenConfig -> Colours[ColourNumber] >> 4) & 0xF;
  1029.                                 Blue    = (MyConfig -> ScreenConfig -> Colours[ColourNumber]     ) & 0xF;
  1030.  
  1031.                                 GT_SetGadgetAttrs(GadgetArray[GAD_RED],PanelWindow,NULL,
  1032.                                     GTSL_Level,Red,
  1033.                                 TAG_DONE);
  1034.  
  1035.                                 GT_SetGadgetAttrs(GadgetArray[GAD_GREEN],PanelWindow,NULL,
  1036.                                     GTSL_Level,Green,
  1037.                                 TAG_DONE);
  1038.  
  1039.                                 GT_SetGadgetAttrs(GadgetArray[GAD_BLUE],PanelWindow,NULL,
  1040.                                     GTSL_Level,Blue,
  1041.                                 TAG_DONE);
  1042.  
  1043.                                 break;
  1044.  
  1045.                             case GAD_NEWFONT:
  1046.  
  1047.                                 BlockWindow(PanelWindow);
  1048.  
  1049.                                 if(PickFont(PanelWindow,MyConfig -> ScreenConfig -> FontName,&MyConfig -> ScreenConfig -> FontHeight,!Kick30))
  1050.                                 {
  1051.                                     SPrintf(SharedBuffer,"%s %ld",MyConfig -> ScreenConfig -> FontName,MyConfig -> ScreenConfig -> FontHeight);
  1052.  
  1053.                                     GT_SetGadgetAttrs(GadgetArray[GAD_CURRENTFONT],PanelWindow,NULL,
  1054.                                         GTTX_Text,    SharedBuffer,
  1055.                                     TAG_DONE);
  1056.                                 }
  1057.  
  1058.                                 ReleaseWindow(PanelWindow);
  1059.  
  1060.                                 break;
  1061.  
  1062.                             case GAD_USE:
  1063.  
  1064.                                 Terminated = TRUE;
  1065.  
  1066.                                 if(!WrongMode)
  1067.                                     PaletteSetup(MyConfig);
  1068.                                 else
  1069.                                 {
  1070.                                     if(MyConfig -> ScreenConfig -> ColourMode != PrivateConfig -> ScreenConfig -> ColourMode)
  1071.                                     {
  1072.                                         switch(MyConfig -> ScreenConfig -> ColourMode)
  1073.                                         {
  1074.                                             case COLOUR_EIGHT:
  1075.  
  1076.                                                 CopyMem(ANSIColours,MyConfig -> ScreenConfig -> Colours,16 * sizeof(UWORD));
  1077.                                                 break;
  1078.  
  1079.                                             case COLOUR_SIXTEEN:
  1080.  
  1081.                                                 CopyMem(EGAColours,MyConfig -> ScreenConfig -> Colours,16 * sizeof(UWORD));
  1082.                                                 break;
  1083.  
  1084.                                             case COLOUR_AMIGA:
  1085.  
  1086.                                                 CopyMem(DefaultColours,MyConfig -> ScreenConfig -> Colours,16 * sizeof(UWORD));
  1087.                                                 break;
  1088.  
  1089.                                             case COLOUR_MONO:
  1090.  
  1091.                                                 CopyMem(AtomicColours,MyConfig -> ScreenConfig -> Colours,16 * sizeof(UWORD));
  1092.                                                 break;
  1093.                                         }
  1094.                                     }
  1095.                                 }
  1096.  
  1097.                                 MyConfig -> ScreenConfig -> MakeScreenPublic    = SZ_GetChecked(GadgetArray[GAD_MAKEPUBLIC]);
  1098.                                 MyConfig -> ScreenConfig -> ShanghaiWindows    = SZ_GetChecked(GadgetArray[GAD_SHANGHAI]);
  1099.                                 MyConfig -> ScreenConfig -> Blinking        = SZ_GetChecked(GadgetArray[GAD_BLINKING]);
  1100.                                 MyConfig -> ScreenConfig -> FasterLayout    = SZ_GetChecked(GadgetArray[GAD_FASTER_LAYOUT]);
  1101.                                 MyConfig -> ScreenConfig -> TitleBar        = SZ_GetChecked(GadgetArray[GAD_TITLEBAR]);
  1102.                                 MyConfig -> ScreenConfig -> UseWorkbench    = SZ_GetChecked(GadgetArray[GAD_USE_WORKBENCH]);
  1103.  
  1104.                                 strcpy(MyConfig -> ScreenConfig -> PubScreenName,SZ_GetString(GadgetArray[GAD_PUBSCREEN_NAME]));
  1105.  
  1106.                                 break;
  1107.  
  1108.                             case GAD_PICKSCREEN:
  1109.  
  1110.                                 if(MyConfig -> ScreenConfig -> UseWorkbench)
  1111.                                 {
  1112.                                     UBYTE DummyBuffer[MAXPUBSCREENNAME + 1];
  1113.  
  1114.                                     BlockWindow(PanelWindow);
  1115.  
  1116.                                     strcpy(DummyBuffer,SZ_GetString(GadgetArray[GAD_PUBSCREEN_NAME]));
  1117.                                     strcpy(SharedBuffer,DummyBuffer);
  1118.  
  1119.                                     if(PickScreen(DummyBuffer))
  1120.                                     {
  1121.                                         if(strcmp(DummyBuffer,SharedBuffer))
  1122.                                         {
  1123.                                             GT_SetGadgetAttrs(GadgetArray[GAD_PUBSCREEN_NAME],PanelWindow,NULL,
  1124.                                                 GTST_String,DummyBuffer,
  1125.                                             TAG_DONE);
  1126.                                         }
  1127.                                     }
  1128.  
  1129.                                     ReleaseWindow(PanelWindow);
  1130.                                 }
  1131.  
  1132.                                 break;
  1133.  
  1134.                             case GAD_CANCEL:
  1135.  
  1136.                                 Terminated = TRUE;
  1137.  
  1138.                                 SaveConfig(PrivateConfig,MyConfig);
  1139.  
  1140.                                 if(!Config -> ScreenConfig -> UseWorkbench && Screen)
  1141.                                 {
  1142.                                     if(!memcmp(Config -> ScreenConfig -> Colours,MyConfig -> ScreenConfig -> Colours,sizeof(UWORD) * 16))
  1143.                                         PaletteSetup(MyConfig);
  1144.                                     else
  1145.                                         PaletteSetup(Config);
  1146.  
  1147.                                     LoadRGB4(VPort,NormalColours,PaletteSize);
  1148.                                 }
  1149.  
  1150.                                 break;
  1151.  
  1152.                             case GAD_DEFAULT:
  1153.  
  1154.                                 *Default    = TRUE;
  1155.  
  1156.                                 Terminated    = TRUE;
  1157.  
  1158.                                 SaveConfig(PrivateConfig,MyConfig);
  1159.  
  1160.                                 if(!Config -> ScreenConfig -> UseWorkbench && Screen)
  1161.                                 {
  1162.                                     if(!memcmp(Config -> ScreenConfig -> Colours,MyConfig -> ScreenConfig -> Colours,sizeof(UWORD) * 16))
  1163.                                         PaletteSetup(MyConfig);
  1164.                                     else
  1165.                                         PaletteSetup(Config);
  1166.  
  1167.                                     LoadRGB4(VPort,NormalColours,PaletteSize);
  1168.                                 }
  1169.  
  1170.                                 break;
  1171.                         }
  1172.                     }
  1173.                 }
  1174.             }
  1175.  
  1176.             RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
  1177.  
  1178.             PopWindow();
  1179.  
  1180.             CloseWindow(PanelWindow);
  1181.         }
  1182.     }
  1183.  
  1184.     FreeGadgets(GadgetList);
  1185.  
  1186.     Node = (struct ModeNode *)ModeList . lh_Head;
  1187.  
  1188.     while(Next = (struct ModeNode *)Node -> VanillaNode . ln_Succ)
  1189.     {
  1190.         FreeVec(Node);
  1191.  
  1192.         Node = Next;
  1193.     }
  1194.  
  1195.     if(PrivateConfig -> ScreenConfig -> DisplayMode != MyConfig -> ScreenConfig -> DisplayMode || Stricmp(PrivateConfig -> ScreenConfig -> FontName,MyConfig -> ScreenConfig -> FontName) || PrivateConfig -> ScreenConfig -> FontHeight != MyConfig -> ScreenConfig -> FontHeight || PrivateConfig -> ScreenConfig -> ColourMode != MyConfig -> ScreenConfig -> ColourMode)
  1196.         return(TRUE);
  1197.  
  1198.     if(PrivateConfig -> ScreenConfig -> MakeScreenPublic != MyConfig -> ScreenConfig -> MakeScreenPublic || PrivateConfig -> ScreenConfig -> ShanghaiWindows != MyConfig -> ScreenConfig -> ShanghaiWindows)
  1199.         return(TRUE);
  1200.  
  1201.     if(PrivateConfig -> ScreenConfig -> Blinking != MyConfig -> ScreenConfig -> Blinking && (MyConfig -> ScreenConfig -> ColourMode == COLOUR_EIGHT || MyConfig -> ScreenConfig -> ColourMode == COLOUR_SIXTEEN))
  1202.         return(TRUE);
  1203.  
  1204.     if(PrivateConfig -> ScreenConfig -> FasterLayout != MyConfig -> ScreenConfig -> FasterLayout && MyConfig -> ScreenConfig -> ColourMode != COLOUR_MONO)
  1205.         return(TRUE);
  1206.  
  1207.     if(PrivateConfig -> ScreenConfig -> TitleBar != MyConfig -> ScreenConfig -> TitleBar || PrivateConfig -> ScreenConfig -> StatusLine != MyConfig -> ScreenConfig -> StatusLine || PrivateConfig -> ScreenConfig -> UseWorkbench != MyConfig -> ScreenConfig -> UseWorkbench)
  1208.         return(TRUE);
  1209.  
  1210.     if(strcmp(PrivateConfig -> ScreenConfig -> PubScreenName,MyConfig -> ScreenConfig -> PubScreenName) && MyConfig -> ScreenConfig -> UseWorkbench)
  1211.         return(TRUE);
  1212.  
  1213.     return(FALSE);
  1214. }
  1215.